package com.amos.muexamclient.sys.service.dto;


import com.alibaba.fastjson.JSONObject;
import com.amos.core.PageDTO;
import com.amos.muexamclient.sys.entity.SysRoleEntity;
import com.amos.muexamcore.core.MuEntity;
import com.amos.muexamcore.core.MuField;
import com.amos.util.StringUtils;
import lombok.Data;

import java.io.Serializable;
import java.util.Date;

/**
 * Copyright © 2018 五月工作室. All rights reserved.
 *
 * @Package com.amos.muexamclient.service.dto
 * @ClassName SysRoleDTO
 * @Description TODO
 * @Author Amos
 * @Modifier
 * @Date 2020-03-24 14:35:56
 * @Version 1.0
 **/
@MuEntity(table = "sys_role", entity = SysRoleEntity.class)
@Data
public class SysRoleDTO extends PageDTO implements Serializable {

    private static final long serialVersionUID = -5162789197684639420L;
    @MuField(remark = "角色名称", type = "varchar", length = 30, column = "role_name")
    private String roleName;

    @MuField(remark = "角色权限字符串", type = "varchar", length = 100, column = "role_key")
    private String roleKey;

    @MuField(remark = "显示顺序", type = "int", column = "role_sort")
    private String roleSort;

    @MuField(remark = "数据范围（1：全部数据权限 2：自定数据权限 3：本部门数据权限 4：本部门及以下数据权限）", type = "char", length = 1, column = "data_scope")
    private String dataScope;

    @MuField(remark = "角色状态（0正常 1停用）", type = "char", length = 1, column = "status")
    private String status;

    @MuField(remark = "创建者", type = "varchar", length = 64, column = "create_by")
    private String createBy;

    @MuField(remark = "更新者", type = "varchar", length = 64, column = "update_by")
    private String updateBy;

    @MuField(remark = "更新时间", type = "datetime", column = "update_time")
    private Date updateTime;

    @MuField(remark = "备注", type = "varchar", length = 500, column = "remark")
    private String remark;

    private Date beginTime;
    private Date endTime;
    /**
     * 部门组（数据权限）
     */
    private String[] deptIds;

    @Override
    public String toString() {
        return JSONObject.toJSONString(this);
    }

    public boolean isAdmin() {
        if (StringUtils.isNullOrEmpty(this.getId()) || "0".equalsIgnoreCase(this.getId())) {
            return true;
        }
        return false;
    }
}
